Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Windows: Emulate MSG_PEEK by read #19777

Merged
merged 45 commits into from
Feb 16, 2022
Merged

Windows: Emulate MSG_PEEK by read #19777

merged 45 commits into from
Feb 16, 2022

Conversation

soulxu
Copy link
Member

@soulxu soulxu commented Feb 2, 2022

Implementing peek by draining the socket and storing the
content of the socket to a buffer.

Additional Description: See #17395
Risk Level: Medium
Testing: Automated
Docs Changes: Pending
Release Notes: Pending
Platform-Specific Features: Windows only

Signed-off-by: He Jie Xu hejie.xu@intel.com
Co-authored-by: Sotiris Nanopoulos sonanopo@microsoft.com

Sotiris Nanopoulos and others added 30 commits November 4, 2021 09:24
Commit Message:

The way we implement i/o events on windows poses problems with peeking messages.

The reason for that is that peeking does not drain the buffer which is an implicit
requirement. This can cause slow clients to make envoy connections to hang.

We solve this issue by implementing peek by draining the socket and storing the
content of the socket to a buffer.

Additional Description: See envoyproxy#17395
Risk Level: Medium
Testing: Automated
Docs Changes: Pending
Release Notes: Pending
Platform Specific Features: Windows only

Co-authored-by: He Jie Xu <hejie.xu@intel.com>
Signed-off-by: Sotiris Nanopoulos <sonanopo@microsoft.com>
Signed-off-by: Sotiris Nanopoulos <sonanopo@microsoft.com>
Signed-off-by: Sotiris Nanopoulos <sonanopo@microsoft.com>
Signed-off-by: Sotiris Nanopoulos <sonanopo@microsoft.com>
Signed-off-by: Sotiris Nanopoulos <sonanopo@microsoft.com>
Signed-off-by: Sotiris Nanopoulos <sonanopo@microsoft.com>
Signed-off-by: Sotiris Nanopoulos <sonanopo@microsoft.com>
Signed-off-by: Sotiris Nanopoulos <sonanopo@microsoft.com>
Signed-off-by: Sotiris Nanopoulos <sonanopo@microsoft.com>
Signed-off-by: Sotiris Nanopoulos <sonanopo@microsoft.com>
Signed-off-by: Sotiris Nanopoulos <sonanopo@microsoft.com>
Signed-off-by: Sotiris Nanopoulos <sonanopo@microsoft.com>
Signed-off-by: Sotiris Nanopoulos <sonanopo@microsoft.com>
Signed-off-by: Sotiris Nanopoulos <sonanopo@microsoft.com>
Signed-off-by: Sotiris Nanopoulos <sonanopo@microsoft.com>
Signed-off-by: Sotiris Nanopoulos <sonanopo@microsoft.com>
Signed-off-by: Sotiris Nanopoulos <sonanopo@microsoft.com>
Signed-off-by: Sotiris Nanopoulos <sonanopo@microsoft.com>
Signed-off-by: Sotiris Nanopoulos <sonanopo@microsoft.com>
Signed-off-by: Sotiris Nanopoulos <sonanopo@microsoft.com>
Signed-off-by: Sotiris Nanopoulos <sonanopo@microsoft.com>
Signed-off-by: He Jie Xu <hejie.xu@intel.com>
Signed-off-by: He Jie Xu <hejie.xu@intel.com>
Signed-off-by: He Jie Xu <hejie.xu@intel.com>
Signed-off-by: He Jie Xu <hejie.xu@intel.com>
Signed-off-by: He Jie Xu <hejie.xu@intel.com>
Signed-off-by: He Jie Xu <hejie.xu@intel.com>
Signed-off-by: He Jie Xu <hejie.xu@intel.com>
Signed-off-by: He Jie Xu <hejie.xu@intel.com>
Signed-off-by: He Jie Xu <hejie.xu@intel.com>
Signed-off-by: He Jie Xu <hejie.xu@intel.com>
Signed-off-by: He Jie Xu <hejie.xu@intel.com>
@soulxu soulxu requested a review from dio as a code owner February 2, 2022 00:03
@soulxu
Copy link
Member Author

soulxu commented Feb 2, 2022

/cc @adisuissa @alyssawilk

thanks @adisuissa give me the error info, and apologize for not making the code right.

@adisuissa said there still other errors, appreciate if can help me spot them out, then let me fix it.

// The length to copy should be size of smallest in the source slice available size and
// the dest slice available size.
uint64_t length_to_copy =
std::min(left_data_size_in_src_slice, std::min(left_data_size_in_dst_slice, left_to_read));
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I correct the length_to_copy calculation.

dest_slice_offset = 0;
}
ASSERT(src_slice_offset <= src_slice.dataSize());
ASSERT(dest_slice_offset <= dest_slice.len_);
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add two assertions for defending.

@adisuissa
Copy link
Contributor

@adisuissa said there still other errors, appreciate if can help me spot them out, then let me fix it.

There is a fuzz error that seems to be in the fuzz test itself, and not due to this PR.
The error is being investigated separately.

@soulxu
Copy link
Member Author

soulxu commented Feb 2, 2022

@adisuissa said there still other errors, appreciate if can help me spot them out, then let me fix it.

There is a fuzz error that seems to be in the fuzz test itself, and not due to this PR. The error is being investigated separately.

got it, thanks

@soulxu
Copy link
Member Author

soulxu commented Feb 2, 2022

/retest

@repokitteh-read-only
Copy link

Retrying Azure Pipelines:
Retried failed jobs in: envoy-presubmit

🐱

Caused by: a #19777 (comment) was created by @soulxu.

see: more, trace.

@soulxu
Copy link
Member Author

soulxu commented Feb 10, 2022

@alyssawilk would you mind take a look at this pr again? Thanks in advance!

@alyssawilk
Copy link
Contributor

tagging Adi for first pass since @wrowe has not been responding.

@soulxu
Copy link
Member Author

soulxu commented Feb 15, 2022

tagging Adi for first pass since @wrowe has not been responding.

Thanks!

@wrowe
Copy link
Contributor

wrowe commented Feb 15, 2022

@davinci26 as much of this was your code, and we still have you on the assignable, envoy-triage and windows-dev teams, are you willing to take a pass at this? [If you would like us to modify your teams we can do that, too.]

@davinci26
Copy link
Member

I will review later today

davinci26
davinci26 previously approved these changes Feb 16, 2022
Copy link
Member

@davinci26 davinci26 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

overall lgtm, thanks for all the hard work on this

Signed-off-by: He Jie Xu <hejie.xu@intel.com>
@soulxu
Copy link
Member Author

soulxu commented Feb 16, 2022

overall lgtm, thanks for all the hard work on this

thanks! done the clean up for those useless logs in the tests.

@soulxu
Copy link
Member Author

soulxu commented Feb 16, 2022

/retest

@repokitteh-read-only
Copy link

Retrying Azure Pipelines:
Retried failed jobs in: envoy-presubmit

🐱

Caused by: a #19777 (comment) was created by @soulxu.

see: more, trace.

Copy link
Contributor

@wrowe wrowe left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, thanks for all your work on this!

@wrowe wrowe merged commit 7cddecb into envoyproxy:main Feb 16, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants